﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreMVVM.ViewModels;
using GeometryViz3D.Model;
using System.Windows.Media.Media3D;

namespace GeometryViz3D.ViewModels
{
    public class PointViewModel : ElementViewModel
    {
        G3DPoint m_point;

        public PointViewModel(IMainViewModel mainVM)
            : this(new G3DPoint(), mainVM)
        {
        }

        public PointViewModel(G3DPoint point, IMainViewModel mainVM)
            : base(point, mainVM)
        {
            m_point = point;
        }

        public G3DPoint Point
        {
            get { return m_point; }
        }

        public Point3D Position
        {
            get { return m_point.Position; }
        }

        public double X
        {
            get { return m_point.Position.X; }
            set
            {
                m_point.Position = new Point3D(value, Y, Z);
                OnPropertyChanged("X");
                RaiseModelChangedEvent();
            }
        }

        public double Y
        {
            get { return m_point.Position.Y; }
            set
            {
                m_point.Position = new Point3D(X, value, Z);
                OnPropertyChanged("Y");
                RaiseModelChangedEvent();
            }
        }

        public double Z
        {
            get { return m_point.Position.Z; }
            set
            {
                m_point.Position = new Point3D(X, Y, value);
                OnPropertyChanged("Z");
                RaiseModelChangedEvent();
            }
        }

        public override string ToString()
        {
            return m_point.ToString();
        }
    }
}
